import request from '@/utils/request'

// 查询ZxBuild列表
export function listZxBuild(query) {
  return request({
    url: '/api/v1/zxbuildList',
    method: 'get',
    params: query
  })
}

// 查询ZxBuild详细
export function getZxBuild(id) {
  return request({
    url: '/api/v1/zxbuild/one/' + id,
    method: 'get'
  })
}
// 查询ZxBuild图
export function getImages(id) {
  return request({
    url: '/api/v1/zxbuild/images/' + id,
    method: 'get'
  })
}
// 删除ZxBuild图
export function removeImageFile(id, name) {
  return request({
    url: '/api/v1/zxbuild/removeImages/' + id + '/' + name,
    method: 'post'
  })
}
// 上传ZxBuild图
export function uploadImages(orderId, files) {
  return request({
    url: '/api/v1/zxbuild/uploads/' + orderId,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: files
  })
}
// 新增ZxBuild
export function addZxBuild(data) {
  data.buildCost = data.buildCost * 100
  return request({
    url: '/api/v1/zxbuild',
    method: 'post',
    data: data
  })
}

// 修改ZxBuild
export function updateZxBuild(data) {
  data.buildCost = data.buildCost * 100
  return request({
    url: '/api/v1/zxbuild',
    method: 'put',
    data: data
  })
}

// 删除ZxBuild
export function delZxBuild(id) {
  return request({
    url: '/api/v1/zxbuild/' + id,
    method: 'delete'
  })
}
export function doMoneyFormat(data) {
  // 获取单元格数据
  if (data === null || data === 0) {
    return ''
  }
  const realVal = parseFloat(data).toFixed(2)
  return parseFloat(realVal) / 100
}

export function doDateFormat(data) {
  // 获取单元格数据
  if (data === null || data === '0001-01-01T00:00:00Z') {
    return null
  }
  const dt = new Date(data)
  return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate()
  // return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate() + ' ' + dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds()
}
